package com.example.demo.study.lambda;

/**
 * Java 8 允许你使用 :: 关键字来引用构造函数
 */
public class LambdaTest4 {

    public static void main(String[] args) {
        //Lambda表达式引用构造函数
        //根据构造器的参数来自动匹配使用哪一个构造器
        Action4Create create = Action4::new;
        Action4 action4 = create.create("xiaoming");
        action4.say();
    }

}

class Action4{
    private String name;
    public  Action4(){

    }
    public Action4(String name){
        this.name = name;
    }
    public void say(){
        System.out.println("name = " + name);
    }
}

interface Action4Create{
    public Action4 create(String name);
}